package com.woniu.gateway.model;


import java.util.List;
import java.util.Map;
import java.util.Set;

public class Result<T> {

    private String msg;
    private Integer code;

    private T data;

    public static <S> Result<S> getResult(Class<S> type){
        Result<S> result=new Result<>();
        result.setCode(200);
        result.setMsg("访问成功");
        return result;
    }

    public T getData() {
        return data;
    }

    public Result<T> setData(T data) {
        this.data = data;
        return this;
    }

    public static <S> Result<S> newInstance(Class<S> type){
        Result<S> result=new Result<>();
        result.setCode(200);
        result.setMsg("访问成功");
        return result;
    }

    public static <S> Result<List<S>> newListInstance(Class<S> type){
        Result<List<S>> re=new Result<>();
        re.setCode(200);
        re.setMsg("访问成功");
        return re;
    }
    public static <S> Result<Set<S>> newSetInstance(Class<S> type){
        Result<Set<S>> re=new Result<>();
        re.setCode(200);
        re.setMsg("访问成功");
        return re;
    }

    public static <S> Result<Map<Integer,List<S>>> newIntegerMapInstance(Class<S> type){
        Result<Map<Integer,List<S>>> re=new Result<>();
        re.setCode(200);
        re.setMsg("访问成功");
        return re;
    }

    public static Result<?> getResult(){
        Result<?> result=new Result<>();
        result.setCode(200);
        result.setMsg("访问成功");
        return result;
    }

    public Result<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Result<T> setCode(Integer code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public Integer getCode() {
        return code;
    }
}
